#!/usr/bin/python3
# -*- coding:UTF-8 -*-
'''=================================
@Motto : 认真生活,热爱生活
@Name :       Bsea
================================='''
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@localhost/blog'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SQLALCHEMY_COMMIT_TEARDOWN'] = True
app.config['SECRET_KEY'] = "abc"
db = SQLAlchemy(app)

# 解决跨域
@app.after_request
def cors(environ):
    environ.headers['Access-Control-Allow-Origin'] = '*'
    environ.headers['Access-Control-Allow-Method'] = '*'
    environ.headers['Access-Control-Allow-Headers'] = 'x-requested-with,content-type'
    return environ


# 路由
@app.route('/')
def hello_world():
    return 'Hello World!'

from api.admin import ad
from api.user import us

app.register_blueprint(user.us)
app.register_blueprint(admin.ad)
